package cn.alex.sso.project.mapper;

import cn.alex.sso.project.entity.SysUser;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author Alex
 * @description 针对表【sys_user(用户表)】的数据库操作Mapper
 * @createDate 2024-09-24 17:05:38
 * @Entity cn.alex.sso.project.entity.SysUser
 */
public interface SysUserMapper extends BaseMapper<SysUser> {

    default LambdaQueryWrapper<SysUser> getQueryWrapper(SysUser sysUser) {
        return new LambdaQueryWrapper<SysUser>()
                .like(StrUtil.isNotBlank(sysUser.getUsername()), SysUser::getUsername, sysUser.getUsername())
                .like(StrUtil.isNotBlank(sysUser.getNickName()), SysUser::getNickName, sysUser.getNickName())
                .eq(ObjUtil.isNotEmpty(sysUser.getSex()), SysUser::getSex, sysUser.getSex())
                .like(StrUtil.isNotBlank(sysUser.getPhoneNum()), SysUser::getPhoneNum, sysUser.getPhoneNum())
                .like(StrUtil.isNotBlank(sysUser.getEmail()), SysUser::getEmail, sysUser.getEmail())
                .eq(ObjUtil.isNotEmpty(sysUser.getStatus()), SysUser::getStatus, sysUser.getStatus());
    }

    IPage<SysUser> selectPage(Page<SysUser> page, @Param("user") SysUser user);
    
    SysUser selectById(Long id);
}




